package com.yjps.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by jessy on 2015/4/20.
 */
public class CommonUtil {

    /**
     *
     * 转化为指定日期形式的字符串
     * */
    public static String dataToString(Date time){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String stringTime = formatter.format(time);
        return stringTime;
    }

    /**
     * 转化为指定日期形式
     * */
    public static Date dataTimeToString(Date time){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String stringTime = formatter.format(time);
        Date date = null;
        try{
            date = formatter.parse(stringTime);
        }catch (ParseException e){
            e.getMessage();
        }
        return date;
    }
}
